package simple;


import java.util.ArrayList;
import java.util.List;

class Solution94 {

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<Integer>();
        traverse(root,list);
        return list;
    }
    public void traverse(TreeNode root,List<Integer> list){
        if(root == null){
            return;
        }
        traverse(root.left,list);
        list.add(root.val);
        traverse(root.right,list);

    }
}